/**
 * Created by Administrator on 2017/1/11.
 */
/**
 * Created by Administrator on 2017/1/11.
 */
import {Component,OnInit} from "@angular/core";
import {Router,ActivatedRoute} from "@angular/router";
import {SecondService} from "../service/second.service";
import { InfiniteScroll } from 'angular2-infinite-scroll';
@Component({
  selector:"second-guess",
  templateUrl:"./guess.html",
  styleUrls:["./guess.less"]
})

export class SecondGuessComponent implements OnInit{
  guessData : any;
  tempGuessData : any;
  tempIngData : any;
  tempEndData : any;           // temp*Data is for switch tab , cache the data.
  type : String ;              // 游戏类型
  selectType : String = "1" ;  // 默认竞猜中 1.
  isSelected : String = "1" ;    // default select class.
  constructor(private router:Router,private ar :ActivatedRoute,private secondService:SecondService){}

  ngOnInit(){
    // first query the data in the guessing,   = 1;
    console.log("guess activeRouter:",this.ar.snapshot.queryParams);
    this.type = this.ar.snapshot.queryParams["type"] ? this.ar.snapshot.queryParams["type"] : "lol";
    console.log("click tab : ",this.type);
    this.guessData = this.secondService.getGuessData(this.selectType).subscribe(res =>this.guessData = res);
  }

  switchType(selectType) {
    console.log("selectType:",selectType);
    this.isSelected = selectType;
    this.guessData = this.secondService.getGuessData(selectType).subscribe(res =>this.guessData = res);
  }

  onScrollDown(){
    console.log("scroll down..........");
  }
}
